package com.wb3.organizer.dao.impl;

import java.util.List;

import org.springframework.orm.hibernate3.HibernateTemplate;

import com.wb3.organizer.dao.NoteDAO;
import com.wb3.organizer.model.Account;
import com.wb3.organizer.model.Note;

public class NoteDAOImpl implements NoteDAO {

	private HibernateTemplate ht;

	public HibernateTemplate getHt() {
		return ht;
	}

	public void setHt(HibernateTemplate ht) {
		this.ht = ht;
	}

	public void save(Note note) {
		ht.save(note);
	}

	public void update(Note note) {
		ht.update(note);
	}

	public void delete(Note note) {
		ht.delete(note);
	}
	
	public Note getNoteById(int note_id){
		return ht.get(Note.class, note_id);
	}

	@SuppressWarnings("unchecked")
	public List<Note> getAll(Account account) {
		List<Note> notes = ht.find("from Note n where n.account = ?", account);
		return notes;
	}

}
